package com.smartrm.trade.application.executor;

import com.smartrm.globalinfrcore.cmd.AbstractCommandContext;
import com.smartrm.trade.domain.SlotVendingMachineDO;
import com.smartrm.trade.domain.valueobject.VendingMachineCommodityListVOJ;
import org.springframework.stereotype.Component;


/*
 * @program: common-starters
 * @description: 货道售卖机展示商品命令
 * @author: houhong
 * @create: 2023-01-11 23:43
 */
@Component
public class ShowCommodityListCmd extends AbstractTradeCmd<VendingMachineCommodityListVOJ> {


    @Override
    public VendingMachineCommodityListVOJ execute(AbstractCommandContext context) throws Exception {
        VendingCommandContext vendingCommandContext = (VendingCommandContext) context;
        Long machineId = vendingCommandContext.getMachineId();
        //货道售卖机实体
        SlotVendingMachineDO machineDO = vendingMachineRepository.getSlotVendingMachineById(machineId);
        //依赖领域层完成
        return machineDO.getCommodityList(tradeDeviceService, tradeCommodityService);
    }
}